__author__ = 'Muscle'


from mui.muicomponent import MUIComponent

class LayoutBase:
    """LayoutBase is a base class to support automatically layout and you should override relayout to customize your layout style
    """
    def __init__(self, **argd):
        assert isinstance(self, MUIComponent)
        self.autoLayout([],
            ['Size Change', 'Child Visible Change', 'Child Size Change', 'Child Add', 'Child Remove'])

    def autoLayout(self, attributes, events=None):
        if events is None:
            events = []

        for attr in attributes:
            self.changeEvent(attr, self.relayout, sync=False)
        for evt in events:
            self.bind(evt, self.relayout, noarg=True, postevent = True)

    def relayout(self):
        #raise 'Panel is an abstract class !!!'
        pass
